home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Caml Light 0.61 / Source / src / lib / pair.mli < prev    next >
Encoding:
Text File  |  1993-09-24  |  1.3 KB  |  28 lines  |  [TEXT/MPS ]

  1. (* Operations on pairs *)
  2.  
  3. value fst : 'a * 'b -> 'a = 1 "field0"
  4.         (* Return the first component of a pair. *)
  5.   and snd : 'a * 'b -> 'b = 1 "field1"
  6.         (* Return the second component of a pair. *)
  7.   and split : ('a * 'b) list -> 'a list * 'b list
  8.         (* Transform a list of pairs into a pair of lists:
  9.            [split [(a1,b1); ...; (an,bn)]] is [([a1; ...; an], [b1; ...; bn])]
  10.         *)
  11.   and combine : 'a list * 'b list -> ('a * 'b) list
  12.         (* Transform a pair of lists into a list of pairs:
  13.            [combine ([a1; ...; an], [b1; ...; bn])] is
  14.               [[(a1,b1); ...; (an,bn)]].
  15.            Raise [Invalid_argument "combine"] if the two lists
  16.            have different lengths. *)
  17.   and map_combine : ('a * 'b -> 'c) -> 'a list * 'b list -> 'c list
  18.         (* [map_combine f ([a1; ...; an], [b1; ...; bn])] is
  19.            [[f (a1, b1); ...; f (an, bn)]].
  20.        Raise [invalid_argument "map_combine"]
  21.        if the two lists have different lengths. *)
  22.   and do_list_combine : ('a * 'b -> 'c) -> 'a list * 'b list -> unit
  23.         (* [do_list_combine f ([a1; ...; an], [b1; ...; bn])] calls in turn
  24.            [f (a1, b1); ...; f (an, bn)], discarding the results.
  25.        Raise [Invalid_argument "do_list_combine"] if the two lists have
  26.        different lengths. *)
  27. ;;
  28.